Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/credential-provider-imds

Package Overview
Dependencies
Maintainers
4
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/credential-provider-imds

AWS credential provider that sources credentials from the EC2 instance metadata service and ECS container metadata service

  • 0.1.0-preview.8
  • preview
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2M
decreased by-2.37%
Maintainers
4
Weekly downloads
 
Created

What is @aws-sdk/credential-provider-imds?

@aws-sdk/credential-provider-imds is a part of the AWS SDK for JavaScript. It provides a way to retrieve AWS credentials from the Instance Metadata Service (IMDS) on Amazon EC2 instances. This is particularly useful for applications running on EC2 instances that need to interact with other AWS services securely.

What are @aws-sdk/credential-provider-imds's main functionalities?

Retrieve Credentials from IMDS

This feature allows you to retrieve AWS credentials from the Instance Metadata Service (IMDS) on an EC2 instance. The code sample demonstrates how to use these credentials to make a call to the AWS STS service to get the caller identity.

const { fromInstanceMetadata } = require('@aws-sdk/credential-provider-imds');
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');

(async () => {
  const client = new STSClient({
    credentials: fromInstanceMetadata(),
  });
  const command = new GetCallerIdentityCommand({});
  const response = await client.send(command);
  console.log(response);
})();

Handle IMDS Timeout

This feature allows you to specify a timeout for the IMDS request. The code sample demonstrates how to set a 1-second timeout for retrieving credentials from IMDS and handle any potential errors.

const { fromInstanceMetadata } = require('@aws-sdk/credential-provider-imds');
const { STSClient, GetCallerIdentityCommand } = require('@aws-sdk/client-sts');

(async () => {
  const client = new STSClient({
    credentials: fromInstanceMetadata({ timeout: 1000 }), // 1 second timeout
  });
  const command = new GetCallerIdentityCommand({});
  try {
    const response = await client.send(command);
    console.log(response);
  } catch (error) {
    console.error('Error retrieving credentials:', error);
  }
})();

Other packages similar to @aws-sdk/credential-provider-imds

Keywords

FAQs

Package last updated on 19 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc